﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using PlanB.ShareDove.ConferenceOrganization.DataLayer.SharePointDataLayer;
using Microsoft.SharePoint;
using PlanB.ShareDove.ConferenceOrganization.BusinessLayer.DataLayerInterface.Entities;

namespace PlanB.ShareDove.ConferenceOrganization.TestLayer.DataLayerTests
{


    /// <summary>
    /// Test DataLayer methods
    /// </summary>
    [TestFixture]
    public class DataLayerTests
    {

        private const string SITE_NAME = "http://enterprisetest/Sites/ShareDove/";
        private const string WEB_NAME = "";

        /// <summary>
        /// Test getting sessions from the SharePoint Data Layer, when we pass SPWeb as a context object
        /// </summary>
        [Test]
        public void TestWithPassedContext()
        {

            IEnumerable<ConferenceSession> sessions = new List<ConferenceSession>();

            using (SPSite site = new SPSite(SITE_NAME))
            {
                using (SPWeb web = site.OpenWeb())
                {

                    SharePointDataLayer dataLayer = new SharePointDataLayer();
                    sessions = dataLayer.GetSessionData(web, null, null);

                }
            }

            Assert.IsTrue(sessions.Count() > 0);
        }



        /// <summary>
        /// Test getting sessions from the SharePoint Data Layer, when we pass string with site and web information as a context object
        /// </summary>
        [Test]
        public void TestWithEmptyContext()
        {
            IEnumerable<ConferenceSession> sessions = new List<ConferenceSession>();

            SharePointDataLayer dataLayer = new SharePointDataLayer();
            sessions = dataLayer.GetSessionData(string.Format("{0};{1}", SITE_NAME, WEB_NAME), null, null);

            Assert.IsTrue(sessions.Count() > 0);

        }


    }
}
